home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacTech 1 to 12
/
MacTech-vol-1-12.toast
/
Tools
/
Bare Bones PopupFuncs 2.8.2
/
xPop ƒ
/
winsize.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-07-05
|
3KB
|
128 lines
#include <SetupA4.h>
#include "xpop.h"
#include <stdio.h>
/* a simple xpop to change the default width of ThinkC's windows */
/* works only with version 5.0.2 */
/* most useful when using a large screen, where the factory default is too wide */
/* defaults to 500 pixels wide (a little narrower than the factory setting) */
/* can be changed by selecting the width you want, than choosing the xpop */
/* eric slosser */
/* please feel free to improve this hack */
enum { kUnknown, kUnsurround, kSurround };
XPopRecPtr gPopRec;
void DoInit(void);
void DoClose(void);
void DoFOpen(void);
void DoFClose(void);
void DoQuery(void);
void DoIt(void);
void SetIt( short w );
pascal void main( XPopRecPtr paramPtr)
{
RememberA0();
SetUpA4();
gPopRec = paramPtr;
switch (paramPtr->message) {
case xpop_init: DoInit(); break;
case xpop_close: DoClose(); break;
case xpop_fopen: DoFOpen(); break;
case xpop_fclose: DoFClose(); break;
case xpop_query: DoQuery(); break;
case xpop_doit: DoIt(); break;
}
RestoreA4();
} /* main */
/*---------------*/
void DoInit(void)
{
InitRecPtr initStuff;
SelectionRecPtr selection;
Handle intH;
selection = (SelectionRecPtr) gPopRec->param;
if ( selection->environment==kTHINK ) {
intH = GetResource('wWid',0);
if ( intH ) {
SetIt( **((int**)intH) );
}
else {
intH = NewHandle(sizeof(int));
**((int**)intH) = 500;
AddResource(intH,'wWid',0,"");
}
}
initStuff = (InitRecPtr) NewPtr(sizeof(InitRec));
if ( initStuff!=NIL ) {
initStuff-> version = 1;
initStuff-> language = -1; /* all languages */
initStuff-> writes = true;
initStuff-> sensitive = false;
initStuff-> getFileMsgs = false;
initStuff-> selStuff = kNeedSelection;
initStuff-> environment = (1<< kTHINK);
}
gPopRec->result = (long) initStuff;
}
/*---------------*/
void DoClose(void)
{}
/*---------------*/
void DoFOpen(void)
{}
/*---------------*/
void DoFClose(void)
{}
/*---------------*/
void DoQuery(void)
{
SelectionRecPtr selection;
gPopRec->result = (long) "\pWinSize(";
selection = (SelectionRecPtr) gPopRec->param;
if ( selection->selEnd == selection->selStart ||
selection->hText == NIL )
return;
gPopRec->result = (long) "\pWinSize";
}
/*---------------*/
void DoIt(void)
{
SelectionRecPtr selection;
PostDoRecPtr rec;
long width;
Handle intH;
selection = (SelectionRecPtr) gPopRec->param;
StringToNum(c2pstr( *selection->hText ),&width);
SetIt( width );
intH = GetResource('wWid',0);
**((int**)intH) = width;
ChangedResource( intH );
rec = (PostDoRecPtr) NewPtr(sizeof(PostDoRec));
if ( rec ) {
rec->version = 1;
rec->paste = false;
}
gPopRec->result = (long) rec;
}
/*---------------*/
void SetIt( short w )
{
asm {
movea.l 0x904,a0
//move.w w,-0x4e70(a0) /* 5.0.1? */
move.w w,-0x5cfc(a0) /* 5.0.2 */
}
}